package bb.lanxing.model.json;

import com.umeng.socialize.net.utils.SocializeProtocolConstants;
import bb.lanxing.util.JsonUtil;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class WeatherData {
    private int cityId;
    private String cityName;
    private double humidity;
    private double latitude;
    private double longitude;
    private double pressure;
    private double tempMax;
    private double tempMin;
    private double temperature;
    private long timestamp;
    private String weatherDesc;
    private String weatherName;
    private double windDeg;
    private double windGust;
    private double windSpeed;

    public WeatherData(JSONObject object) {
        if (JsonUtil.getObjectValue("coord", object) != null) {
            this.latitude = JsonUtil.getDoubleValue("lat", object);
            this.longitude = JsonUtil.getDoubleValue("lon", object);
        }
        JSONArray arrayValue = JsonUtil.getArrayValue("weather", object);
        if (arrayValue != null && arrayValue.length() > 0) {
            try {
                this.weatherName = JsonUtil.getStringValue("main", (JSONObject) arrayValue.get(0));
                this.weatherDesc = JsonUtil.getStringValue("description", (JSONObject) arrayValue.get(0));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        JSONObject objectValue = JsonUtil.getObjectValue("main", object);
        if (objectValue != null) {
            this.pressure = JsonUtil.getDoubleValue("pressure", objectValue);
            this.humidity = JsonUtil.getDoubleValue("humidity", objectValue);
            this.temperature = JsonUtil.getDoubleValue("temp", objectValue);
            this.tempMin = JsonUtil.getDoubleValue("temp_min", objectValue);
            this.tempMax = JsonUtil.getDoubleValue("temp_max", objectValue);
        }
        JSONObject objectValue2 = JsonUtil.getObjectValue("wind", object);
        if (objectValue2 != null) {
            this.windSpeed = JsonUtil.getDoubleValue("speed", objectValue2);
            this.windDeg = JsonUtil.getDoubleValue("deg", objectValue2);
            this.windGust = JsonUtil.getDoubleValue("gust", objectValue2);
        }
        this.timestamp = JsonUtil.getLongValue(SocializeProtocolConstants.PROTOCOL_KEY_DT, object);
        this.cityId = JsonUtil.getIntegerValue("id", object);
        this.cityName = JsonUtil.getStringValue("name", object);
    }

    public String getCityName() {
        return this.cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public double getLatitude() {
        return this.latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return this.longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public String getWeatherName() {
        return this.weatherName;
    }

    public void setWeatherName(String weatherName) {
        this.weatherName = weatherName;
    }

    public String getWeatherDesc() {
        return this.weatherDesc;
    }

    public void setWeatherDesc(String weatherDesc) {
        this.weatherDesc = weatherDesc;
    }

    public double getPressure() {
        return this.pressure;
    }

    public void setPressure(double pressure) {
        this.pressure = pressure;
    }

    public double getHumidity() {
        return this.humidity;
    }

    public void setHumidity(double humidity) {
        this.humidity = humidity;
    }

    public double getTemperature() {
        return this.temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }

    public double getTempMin() {
        return this.tempMin;
    }

    public void setTempMin(double tempMin) {
        this.tempMin = tempMin;
    }

    public double getTempMax() {
        return this.tempMax;
    }

    public void setTempMax(double tempMax) {
        this.tempMax = tempMax;
    }

    public double getWindSpeed() {
        return this.windSpeed;
    }

    public void setWindSpeed(double windSpeed) {
        this.windSpeed = windSpeed;
    }

    public double getWindDeg() {
        return this.windDeg;
    }

    public void setWindDeg(double windDeg) {
        this.windDeg = windDeg;
    }

    public double getWindGust() {
        return this.windGust;
    }

    public void setWindGust(double windGust) {
        this.windGust = windGust;
    }

    public long getTimestamp() {
        return this.timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public int getCityId() {
        return this.cityId;
    }

    public void setCityId(int cityId) {
        this.cityId = cityId;
    }
}
